﻿<%@ WebHandler Language="C#" Class="PicHandler" %>

using System;
using System.Web;
using SeDuce.BLL;
using SeDuce.Model;
using System.Collections.Generic;

public class PicHandler : IHttpHandler {

    Lazy_Yu<PicBLL> lazyPicBLL = new Lazy_Yu<PicBLL>(() => new PicBLL());
    public PicBLL LazyPicBLL
    {
        get { return this.lazyPicBLL.Value; }
    }
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        PicData picData = context.Request.Form["picdata"].ToString().FromJsonTo<PicData>();

        JSONStatus status = new JSONStatus() { Status = "0" };
        if (picData.PicList.Count > 0)
        {
            if (!this.LazyPicBLL.UpdatePics(picData.PicList))
            {
                status.Status = "1";
            }
        }

        context.Response.Write(status.ToJSON());
        context.Response.End();
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
}
